<?php
$config = include 'db.php';
$db = new PDO($config['dsn'],$config['username'],$config['password']);
$username=$_SESSION['user'];
$statement=$db->prepare('select * from user where username=:username');
$statement->execute([':username'=>$username]);
$user=$statement->fetch();
if($user['sex']==='男'){
    echo "欢迎你：".$username."先生";
}
if($user['sex']==='女'){
    echo "欢迎你：".$username."女士";
}